]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Do not skip CoglError parameters
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 14 Apr 2016 15:13:17 +0000 (17:13 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 15 Apr 2016 16:22:18 +0000 (18:22 +0200)
While CoglError is a define to GError, it doesn't follow the convention
of ignoring errors when NULL is passed, but rather treats the error as
fatal :-(
That's clearly unwanted for a compositor, so make sure to always pass
an error parameter where a runtime error is possible

https://bugzilla.gnome.org/show_bug.cgi?id=765061

src/st/st-private.c
src/st/st-texture-cache.c
src/st/st-theme-node-drawing.c

index e5a27019b77c37b3c844401c9d970eb7066851d2..b00a2bdd7268f80590e287ac789234a0f77126ef 100644 (file)
@@ -347,6 +347,7 @@ _st_create_shadow_pipeline (StShadow    *shadow_spec,
 {
   ClutterBackend *backend = clutter_get_default_backend ();
   CoglContext *ctx = clutter_backend_get_cogl_context (backend);
+  CoglError *error = NULL;
 
   static CoglPipeline *shadow_pipeline_template = NULL;
 
@@ -377,7 +378,13 @@ _st_create_shadow_pipeline (StShadow    *shadow_spec,
                                                          COGL_PIXEL_FORMAT_A_8,
                                                          rowstride_out,
                                                          pixels_out,
-                                                         NULL));
+                                                         &error));
+
+  if (error)
+    {
+      g_warning ("Failed to allocate texture: %s", error->message);
+      cogl_error_free (error);
+    }
 
   g_free (pixels_out);
 
index cec97d538e0f64dd148473fc73d50f6a541f83b4..1c718acb9be584a2fe75ae7c7904b8e4f9a0c501 100644 (file)
@@ -461,14 +461,24 @@ pixbuf_to_cogl_texture (GdkPixbuf *pixbuf)
 {
   ClutterBackend *backend = clutter_get_default_backend ();
   CoglContext *ctx = clutter_backend_get_cogl_context (backend);
+  CoglError *error = NULL;
+  CoglTexture2D *texture;
+
+  texture = cogl_texture_2d_new_from_data (ctx,
+                                           gdk_pixbuf_get_width (pixbuf),
+                                           gdk_pixbuf_get_height (pixbuf),
+                                           gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888,
+                                           gdk_pixbuf_get_rowstride (pixbuf),
+                                           gdk_pixbuf_get_pixels (pixbuf),
+                                           &error);
+
+  if (error)
+    {
+      g_warning ("Failed to allocate texture: %s", error->message);
+      cogl_error_free (error);
+    }
 
-  return COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx,
-                                                      gdk_pixbuf_get_width (pixbuf),
-                                                      gdk_pixbuf_get_height (pixbuf),
-                                                      gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888,
-                                                      gdk_pixbuf_get_rowstride (pixbuf),
-                                                      gdk_pixbuf_get_pixels (pixbuf),
-                                                      NULL));
+  return texture ? COGL_TEXTURE (texture) : NULL;
 }
 
 static cairo_surface_t *
@@ -632,6 +642,8 @@ st_texture_cache_reset_texture (StTextureCachePropertyBind *bind,
       (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32 ||
        cairo_image_surface_get_format (surface) == CAIRO_FORMAT_RGB24))
     {
+      CoglError *error = NULL;
+
       texdata = COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx,
                                                              cairo_image_surface_get_width (surface),
                                                              cairo_image_surface_get_height (surface),
@@ -639,13 +651,18 @@ st_texture_cache_reset_texture (StTextureCachePropertyBind *bind,
                                                              COGL_PIXEL_FORMAT_BGRA_8888 : COGL_PIXEL_FORMAT_BGR_888,
                                                              cairo_image_surface_get_stride (surface),
                                                              cairo_image_surface_get_data (surface),
-                                                             NULL));
+                                                             &error));
 
       if (texdata)
         {
           clutter_texture_set_cogl_texture (bind->texture, texdata);
           cogl_object_unref (texdata);
         }
+      else if (error)
+        {
+          g_warning ("Failed to allocate texture: %s", error->message);
+          cogl_error_free (error);
+        }
 
       clutter_actor_set_opacity (CLUTTER_ACTOR (bind->texture), 255);
     }
index 1f28ed9fd585ad37bfca3ef3c93c57e543aa863c..057b716b4a04cda047a89637bb4f6cf058e48b7d 100644 (file)
@@ -71,6 +71,7 @@ create_corner_material (StCornerSpec *corner)
 {
   ClutterBackend *backend = clutter_get_default_backend ();
   CoglContext *ctx = clutter_backend_get_cogl_context (backend);
+  CoglError *error = NULL;
   CoglHandle texture;
   cairo_t *cr;
   cairo_surface_t *surface;
@@ -172,7 +173,14 @@ create_corner_material (StCornerSpec *corner)
                                                          CLUTTER_CAIRO_FORMAT_ARGB32,
                                                          rowstride,
                                                          data,
-                                                         NULL));
+                                                         &error));
+
+  if (error)
+    {
+      g_warning ("Failed to allocate texture: %s", error->message);
+      cogl_error_free (error);
+    }
+
   g_free (data);
   g_assert (texture != COGL_INVALID_HANDLE);
 
@@ -958,6 +966,7 @@ st_theme_node_prerender_background (StThemeNode *node,
 {
   ClutterBackend *backend = clutter_get_default_backend ();
   CoglContext *ctx = clutter_backend_get_cogl_context (backend);
+  CoglError *error = NULL;
   StBorderImage *border_image;
   CoglHandle texture;
   guint radius[4];
@@ -1277,7 +1286,13 @@ st_theme_node_prerender_background (StThemeNode *node,
                                                          CLUTTER_CAIRO_FORMAT_ARGB32,
                                                          rowstride,
                                                          data,
-                                                         NULL));
+                                                         &error));
+
+  if (error)
+    {
+      g_warning ("Failed to allocate texture: %s", error->message);
+      cogl_error_free (error);
+    }
 
   cairo_destroy (cr);
   cairo_surface_destroy (surface);